import jwt from 'jsonwebtoken'
import { JWTSECRETKEY, TESTTOKEN } from './contant'
import { tokenParams } from '../../global'

// 生成token
export const token = (params: object): string => {
    return jwt.sign(params, JWTSECRETKEY)
}

// 解析token
export const parseToken = (): tokenParams => {
    return jwt.verify(TESTTOKEN, JWTSECRETKEY, { algorithms: ['HS256'] }) as tokenParams
}
